from django.db import models


class Category(models.Model):
    """文章分类模型"""
    name = models.CharField(max_length=100)
    create_time = models.DateTimeField(auto_now_add=True)


class Article(models.Model):
    """文章模型"""
    title = models.CharField(max_length=100, null=False)
    content = models.TextField(null=False)
    create_time = models.DateTimeField(auto_now_add=True)

    category = models.ForeignKey('Category', on_delete=models.CASCADE)
    author = models.ForeignKey('front.FrontUser', on_delete=models.CASCADE, null=True)


class Comment(models.Model):
    """评论模型"""
    content = models.TextField(null=False)
    origin_content = models.ForeignKey('self', on_delete=models.CASCADE, null=True)
